let context =null 
const initContext=(vue)=>{
	context = vue;
}

//注册
const registerAsync = async(usercell,pwd,authCode)=>{
	let requrl=`${context.serverUrl}/Account/Register`;
	let [error, result] = await uni.request({
		url:requrl,
		method:"POST",
		data:{
			UserId:usercell,
			Password:pwd,
			AuthCode:authCode,
		}
	});
	if (!error && result.statusCode == 200) {
		return result.data;
	}
	return null;
}

//发送验证码
const phoneVerificationCodeAsync = async(userPhone)=>{
	let requrl=`${context.serverUrl}/Account/PhoneAuthCode`;
	let [error, result] = await uni.request({
		url:requrl,
		method:"POST",
		data:{
			PhoneId:userPhone,
		}
	});
	if (!error && result.statusCode == 200) {
		return result.data;
	}
	return null;
}

const registerService = {
	initContext,
	registerAsync,
	phoneVerificationCodeAsync,
}

export default registerService